// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Vuex from 'vuex'
import iView from 'iview'
import 'iview/dist/styles/iview.css'
import 'lodash'
import moment from 'moment'
import 'moment/locale/zh-cn'
moment.locale('zh-cn')

window.moment = moment
window.Vue = Vue
window.Vuex = Vuex
Vue.prototype._ = _
Vue.use(Vuex)
Vue.use(iView)

require('./directive')
require('./filter')

Vue.config.productionTip = false

Vue.component('GlobalSearchInput', require('@/components/GlobalSearchInput.vue'))
const router = require('./router').default
const store = require('@/store/global').default
router.beforeEach((to, from, next) => {
  if (to.name === 'Search') {
    store.commit('changeSearchKeyword', to.params.content)
    store.commit('changeSearchTab', to.params.tab)
  }
  next()
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: {App: require('./App')}
})
